import AlertComponent from './alert.vue'

const Alert = {}

Alert.install =  (Vue) =>{
    const AlertConstruct = Vue.extend(AlertComponent)
    const instace = new AlertConstruct()

    instace.$mount(document.createElement('div'))
    document.body.appendChild(instace.$el)

    // 4. 添加实例方法
    Vue.prototype.$alert =  (msg)=> {
      // 逻辑...
      instace.type='alert'
      instace.msg = msg
      instace.isShow = true
    }

    Vue.prototype.$confirm =  (msg,success,cancel)=> {
        // 逻辑...
        instace.type='confirm'
        instace.msg = msg
        instace.isShow = true
        if (typeof success !== 'undefined') {
            instace.success=success
        }
        if (typeof cancel !== 'undefined') {
            instace.cancel=cancel
        }
      }
  }

  export default Alert